<?php
class Persona extends AppModel {
	var $name = 'Persona';
	var $useTable = 'personas';
	var $displayField = 'nombre';
	var $validate = array(
		'id' => array(
			'blank' => array(
				'rule' => array('blank'),
				'on' => 'create' 
			)
		),
		'ci_rif' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '14')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'nit' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '14')
			)
		),
		'contacto' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '255')
			)
		),
		'nombre' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '255')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'created' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'email' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '150')
			)
		),
		'direccion' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '500')
			)
		),
		'zonapartidacurso' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '50')
			)
		),
		'boletin' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'empresa_id' => array(
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'medio_publicitario_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'usuario' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '100')
			)
		),
		'clave' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '100')
			)
		),
		'activo' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'usuario_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'telefono' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '100')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
		),
	);

	var $belongsTo = array(
		'Empresa' => array(
			'className' => 'Persona',
			'foreignKey' => 'empresa_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'MedioPublicitario' => array(
			'className' => 'MedioPublicitario',
			'foreignKey' => 'medio_publicitario_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Usuario' => array(
			'className' => 'Persona',
			'foreignKey' => 'usuario_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	var $hasMany = array(
		'CandidatoObservacion' => array(
			'className' => 'CandidatoObservacion',
			'foreignKey' => 'persona_id'
		),
		'CartaPagoPersona' => array(
			'className' => 'CartaPago',
			'foreignKey' => 'persona_id'
		),
		'CartaPagoUsuario' => array(
			'className' => 'CartaPago',
			'foreignKey' => 'usuario_id'
		),
		'Clase' => array(
			'className' => 'Clase',
			'foreignKey' => 'instructor_id'
		),
		'Encuesta' => array(
			'className' => 'Encuesta',
			'foreignKey' => 'persona_id'
		),
		'FacturaPersona' => array(
			'className' => 'Factura',
			'foreignKey' => 'persona_id'
		),
		'FacturaUsuario' => array(
			'className' => 'Factura',
			'foreignKey' => 'usuario_id'
		),
		'FacturaCurso' => array(
			'className' => 'Factura',
			'foreignKey' => 'persona_id'
		),
		'Inasistencia' => array(
			'className' => 'Inasistencia',
			'foreignKey' => 'persona_id'
		),
		'Instructor' => array(
			'className' => 'Instructor',
			//'foreignKey' => 'persona_id'
			'foreignKey' => 'id'
		),
		'InstructorCurso' => array(
			'className' => 'InstructorCurso'
			,'foreignKey' => 'persona_id'
		),
		'PersonaEmail' => array(
			'className' => 'PersonaEmail',
			'foreignKey' => 'persona_id'
		),
		'PersonaObservacion' => array(
			'className' => 'PersonaObservacion',
			'foreignKey' => 'persona_id'
		),
		'PersonaPlanHosting' => array(
			'className' => 'PersonaPlanHosting',
			'foreignKey' => 'persona_id'
		),
		'PersonaTelefono' => array(
			'className' => 'PersonaTelefono',
			'foreignKey' => 'persona_id'
		),
		'PresupuestoPersona' => array(
			'className' => 'Presupuesto',
			'foreignKey' => 'persona_id'
		),
		'PresupuestoUsuario' => array(
			'className' => 'Presupuesto',
			'foreignKey' => 'usuario_id'
		),
		'ReciboGastoUsuario' => array(
			'className' => 'ReciboGasto',
			'foreignKey' => 'usuario_id'
		),
		'ReciboGastoProveedor' => array(
			'className' => 'ReciboGasto',
			'foreignKey' => 'proveedor_id'
		),
		'ReciboGastoInstructor' => array(
			'className' => 'ReciboGasto',
			'foreignKey' => 'instructor_id'
		),
		'ReciboVentaPersona' => array(
			'className' => 'ReciboVenta',
			'foreignKey' => 'persona_id'
		),
		'ReciboVentaUsuario' => array(
			'className' => 'ReciboVenta',
			'foreignKey' => 'usuario_id'
		),
		'ReciboVentaCurso' => array(
			'className' => 'ReciboVentaCurso',
			'foreignKey' => 'persona_id'
		),
		'RecordatorioCartaPagoPersona' => array(
			'className' => 'RecordatorioCartaPago',
			'foreignKey' => 'persona_id'
		),
		'RecordatorioCartaPagoUsuario' => array(
			'className' => 'RecordatorioCartaPago',
			'foreignKey' => 'usuario_id'
		),
		'Solicitud' => array(
			'className' => 'Solicitud',
			'foreignKey' => 'persona_id'
		),
		'SolicitudEsperaPersona' => array(
			'className' => 'SolicitudEspera',
			'foreignKey' => 'persona_id'
		),
		'SolicitudEsperaUsuario' => array(
			'className' => 'SolicitudEspera',
			'foreignKey' => 'usuario_id'
		),
		'SolicitudEvento' => array(
			'className' => 'SolicitudEvento',
			'foreignKey' => 'usuario_id'
		)	
	);


	var $hasAndBelongsToMany = array(
		'Grupo' => array(
			'className' => 'Grupo',
			'joinTable' => 'grupos_personas',
			'foreignKey' => 'persona_id',
			'associationForeignKey' => 'grupo_id',
			'unique' => true
		),
		'TipoPersona' => array(
			'className' => 'TipoPersona',
			'joinTable' => 'personas_tipos_personas',
			'foreignKey' => 'persona_id',
			'associationForeignKey' => 'tipo_persona_id',
			'unique' => true
		)
	);

}
?>